package com.zunipe.trainticketsystem.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class TrainTicketDBHelper extends SQLiteOpenHelper {
    public TrainTicketDBHelper(@Nullable Context context) {
        super(context, "train_ticket.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE users(id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT NOT NULL, phone TEXT NOT NULL)");
        db.execSQL("CREATE TABLE trains(id INTEGER PRIMARY KEY AUTOINCREMENT, train_number TEXT NOT NULL, place_of_start TEXT NOT NULL, place_of_end TEXT NOT NULL, start_time TEXT NOT NULL, end_time TEXT NOT NULL, type TEXT NOT NULL, price REAL NOT NULL, count INTEGER NOT NULL)");
        db.execSQL("CREATE TABLE orders(id INTEGER PRIMARY KEY AUTOINCREMENT, train_id INTEGER NOT NULL, user_id INTEGER NOT NULL, order_number String NOT NULL, time TEXT NOT NULL, status TEXT NOT NULL, price REAL NOT NULL)");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
